home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / cfexit.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  2.1 KB  |  66 lines

  1. <!--- This example shows the use of CFEXIT, and
  2. is a read-only example --->
  3. <HTML>
  4. <HEAD>
  5. <TITLE>CFEXIT Example</TITLE>
  6. </HEAD>
  7.  
  8. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  9. <BODY  bgcolor="#FFFFD5">
  10.  
  11. <H3>CFEXIT Example</H3>
  12.  
  13. <P>CFEXIT can be used to abort the processing of the
  14. currently executing CFML custom tag.  Execution will resume
  15. immediately following the invocation of the custom tag in the
  16. page that called the tag.
  17. <H3>Usage of CFEXIT</H3>
  18. <P>CFEXIT is used primarily to perform a conditional stop
  19. of processing inside of a custom tag.  CFEXIT returns control
  20. to the page that called that custom tag, or in the case of
  21. a tag called by another tag, to the calling tag.
  22.  
  23. <!--- CFEXIT can be used inside a CFML custom tag, as
  24. follows: --->
  25. <!--- Place this code (uncomment the appropriate
  26. sections) inside the CFUSION/customtags directory --->
  27.  
  28. <!--- MyCustomTag.cfm --->
  29. <!--- this simple custom tag checks for the existence
  30. of myValue1 and myValue2.  If they are both defined,
  31. the tag adds them and returns the result to the calling
  32. page in the variable "result".  If either or both of the
  33. expected attribute variables is not present, an error message
  34. is generated, and CFEXIT returns control to the
  35. calling page.  --->
  36.  
  37. <!--- <CFIF NOT IsDefined("attributes.myValue2")>
  38.             <CFSET caller.result = "Value2 is not defined">
  39.             <CFEXIT METHOD="ExitTag">
  40.       <CFELSEIF NOT IsDefined("attributes.myValue1")>
  41.             <CFSET caller.result = "Value1 is not defined">
  42.             <CFEXIT METHOD="ExitTag">
  43.       <CFELSE>
  44.               <CFSET value1 = attributes.myValue1>        
  45.               <CFSET value2 = attributes.myValue2>        
  46.             <CFSET caller.result = value1 + value2>
  47.       </CFIF> --->
  48. <!--- End MyCustomTag.cfm --->
  49.  
  50. <!--- And place this code inside your page --->      
  51.  
  52. <!--- <P>The call to the custom tag, and then the result:
  53. <CF_myCustomTag
  54.         myvalue2 = 4>      
  55. <CFOUTPUT>#result#</cFOUTPUT>  --->
  56.  
  57. <P>If CFEXIT is used outside of a custom tag, it functions
  58. like a CFABORT.  For example, the text after this message
  59. will not be processed:
  60. <CFEXIT>
  61. <P>This text will not be executed due to the existence of 
  62. the CFEXIT tag above it.
  63.  
  64. </BODY>
  65. </HTML>       
  66.